package mobi.weq.servlets.data;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

import mobi.weq.dao.PollutionData;
import mobi.weq.model.SensorObservation;
import mobi.weq.model.vo.GridVo;
import mobi.weq.util.map.Bounds;

/**
 * Servlet implementation class
 */
@WebServlet("/data/currentsensor")
public class GetCurrentSensorData extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// lat, long
		// grid id
		String latString = request.getParameter("latitude");
		String lngString = request.getParameter("longitude");
		String gridId = request.getParameter("gridId");

		// 55.904523310371176
		// -3.4560418031250047

		Gson g = new Gson();
		// try {
		// response.getWriter().print(g.toJson(PollutionData.getCurrentDataForPosition(Double.valueOf(latString),
		// Double.valueOf(lngString))));
		// } catch (NumberFormatException e) {
		// e.printStackTrace();
		// } catch (SQLException e) {
		// e.printStackTrace();
		// }
		response.getWriter().print(g.toJson(PollutionData.getDummySensorObservation()));
	}

}
